<?php
namespace App\Http\Controllers\API;

use App\Http\Controllers\Controller;
use App\Models\AdminInfo;
use Illuminate\Support\Facades\Auth;

/**
 * Created by PhpStorm.
 * User: 都大爽
 * Date: 2017/6/26
 * Time: 14:02
 */

class AdminController extends Controller
{

    public function index()
    {
        //
    }

    /**
     * 获取当前登录用户信息
     * @return mixed
     */
    public function getProfile()
    {
        $authUser = Auth::user();
        $authUser->profile_info = AdminInfo::where('admin_id' , $authUser->id)->first();
        return $authUser->toArray();
    }

    /**
     * 获取当前登录用户的权限列表
     * @return array
     */
    public function getUserPermissionList()
    {
        $permissionList = [];
        $authUser = Auth::user();
        foreach ($authUser->roles as $role){
            foreach ($role->perms as $permission){
                $permissionList[] = $permission->name;
            }
        }
        return $permissionList;
    }
}